package com.xiaozhengkeji.xiaozhengblog.api;

import com.xiaozhengkeji.xiaozhengblog.base.entitys.ArticleClassEntity;
import com.xiaozhengkeji.xiaozhengblog.base.entitys.ArticleTagEntity;
import com.xiaozhengkeji.xiaozhengblog.base.service.ArticleTagEntityService;
import com.xiaozhengkeji.xiaozhengblog.base.service.SystemUserEntityService;
import com.xiaozhengkeji.xiaozhengblog.bean.ResponseBean;
import com.xiaozhengkeji.xiaozhengblog.bean.type.ResCodeType;
import com.xiaozhengkeji.xiaozhengblog.utils.page.ListPager;
import com.xiaozhengkeji.xiaozhengblog.utils.page.Pagers;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文章标签管理
 */
@Slf4j
@RestController
@RequestMapping("/web/article/tag")
public class ArticleTagApi {

    ArticleTagEntityService articleTagEntityService;
    SystemUserEntityService systemUserEntityService;

    @ApiOperation("获取当前全部的标签")
    @PostMapping("getDefault")
    public ResponseBean getDefault(@ApiParam("分类名 空为查询全部") @RequestParam("query") String query,
                              @ApiParam("第几页") @RequestParam("pageNum") Integer pageNum,
                              @ApiParam("每页数量") @RequestParam("pageSize") Integer pageSize) {
        List<ArticleTagEntity> articleTagEntities = articleTagEntityService.queryByAll(new ArticleTagEntity());
        ListPager<ArticleTagEntity> articleTagEntityListPager = Pagers.newListPager(pageSize, articleTagEntities);
        return new ResponseBean(ResCodeType.Success, "!", articleTagEntityListPager.getPage(pageNum), articleTagEntities.size());
    }
}
